package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/pay"
	"github.com/streadway/amqp"
)

//订单支付成功，业务处理
func main() {
	rpcPay := new(pay.Pay).Init()
	defer rpcPay.Close()
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("pay.log.paySucAgent"))
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("pay.queue.paySucAgent"), func(msg amqp.Delivery) {
		orderSn := string(msg.Body)
		reply := false
		if err := rpcPay.PayAgent(context.Background(), &orderSn, &reply); err != nil {
			utils.Logerr.Printf("支付成功清分资金记账处理任务调用失败，orderSn:%s, err:%s", orderSn, err)
			return
		}
	})

	if err != nil {
		utils.Logerr.Printf("支付成功异步回调任务错误，err: %s", err.Error())
	}
}
